Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
unist-util-map
Advanced tools
Create a new Unist tree with all nodes that mapped by the provided function
unist utility to create a new tree by mapping all nodes with the given function.
npm:
npm install unist-util-map
var u = require('unist-builder')
var map = require('unist-util-map')
var tree = u('tree', [
u('leaf', 'leaf 1'),
u('node', [u('leaf', 'leaf 2')]),
u('void'),
u('leaf', 'leaf 3')
])
var next = map(tree, function(node) {
return node.type === 'leaf'
? Object.assign({}, node, {value: 'CHANGED'})
: node
})
console.dir(next, {depth: null})
Yields:
{
type: 'tree',
children: [
{ type: 'leaf', value: 'CHANGED' },
{ type: 'node', children: [ { type: 'leaf', value: 'CHANGED' } ] },
{ type: 'void' },
{ type: 'leaf', value: 'CHANGED' }
]
}
…note that tree
is not mutated.
map(tree, mapFn)
Create a new tree by mapping all nodes with the given function.
function mapFn(node[, index, parent])
Function called with a node to produce a new node.
node
(Node
) — Current node being processedindex
(number?
) — Index of node
, or null
parent
(Node?
) — Parent of node
, or null
Node
— Node to be used in the new tree.
Its children are not used: if the original node has children, those are mapped.
unist-util-filter
— Create a new tree with all nodes that pass the given functionunist-util-flatmap
— Create a new tree by expanding a node into manyunist-util-remove
— Remove nodes from treesunist-util-select
— Select nodes with CSS-like selectorsunist-util-visit
— Recursively walk over nodesunist-builder
— Creating treesSee contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
FAQs
unist utility to create a new tree by mapping all nodes
The npm package unist-util-map receives a total of 78,313 weekly downloads. As such, unist-util-map popularity was classified as popular.
We found that unist-util-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.